package com.frank.work.task;

import com.frank.work.*;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @author 小石潭记
 * @date 2021/12/21 11:15
 * @Description: ${todo}
 */
@Component("RoleInfoGroupNodeTask")
public class RoleInfoGroupNodeTask extends AbstractPipelineNodeTask {

    @Override
    public Object deal(Object args, PipelineNode pipelineNode) {
        if (args instanceof Optional) {
            Optional optional = (Optional) args;
            return handleTask((BasicInfo) optional.get());
        }
        return handleTask((BasicInfo) args);
    }

    /**
     * 处理业务逻辑
     * @param basicInfo
     */
    private Optional<BasicInfo> handleTask(BasicInfo basicInfo) {
        RoleInfo roleInfo = new RoleInfo();
        roleInfo.setId(1);
        roleInfo.setRoleName("超级管理员");
        basicInfo.setRoleInfo(roleInfo);
        return Optional.ofNullable(basicInfo);
    }
}
